﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using RooHui.Infrastructure.Entities.EFContext;
using RooHui.Infrastructure.Entities.Repository;
using RooHui.Infrastructure.Entities.Enum;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class ProjectHistory : IAccessible<P_ProjectHistory, ProjectHistory>, ILogicEntity<P_ProjectHistory, ProjectHistory>
    {
        public int ID { get; set; }
        public int ProjectId { get; set; }
        public ProjectStatus PreState { get; set; }
        public ProjectStatus NewStatus { get; set; }
        public string ChangeContent { get; set; }
        public DateTime CreateTime { get; set; }
        public string CreateUser { get; set; }

        protected override void Covariant(P_ProjectHistory model)
        {
            if (model != null)
            {
                this.ChangeContent = model.ChangeContent;
                this.CreateTime = model.CreateTime;
                this.CreateUser = model.CreateUser;
                this.ID = model.ID;
                this.NewStatus = (ProjectStatus)model.NewStatus;
                this.PreState = (ProjectStatus)model.PreState;
                this.ProjectId = model.ProjectId;
            }
        }

        protected override P_ProjectHistory Inverter(ProjectHistory model)
        {
            if (model != null)
            {
                return new P_ProjectHistory()
                {
                    ChangeContent = model.ChangeContent,
                    CreateTime = model.CreateTime,
                    CreateUser = model.CreateUser,
                    ID = model.ID,
                    NewStatus = (int)model.NewStatus,
                    PreState = (int)model.PreState,
                    ProjectId = model.ProjectId
                };
            }
            return null;
        }

        public ProjectHistory Set(P_ProjectHistory dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
